home *** CD-ROM | disk | FTP | other *** search
/ Mission to McDonaldLand / Mission To McDonaldLand.iso / calnz.dxr / 00030_Script_LockTo < prev    next >
Text File  |  1998-10-25  |  2KB  |  103 lines

  1. property myChannel,LockTo,Tracking,Permanent,LockState,OrigLoc
  2.  
  3. on birth me,myChannelP,LockToP,PermanentP,CallBackP,OrigLocP
  4.   global handcursor
  5.   set origLoc = origLocP
  6.   set lockCount = 0
  7.   set lockSate = FALSE
  8.   set myChannel = myChannelP
  9.   --lock to is of formate [lock to point:[list of rects],...]
  10.   set LockTo = LockToP
  11.   set tracking = False
  12.   set permanent = permanentP
  13.   set callback = callbackP
  14.   append(the scriptInstancelist of sprite mycHannel ,me)
  15.   append(the actorlist,me)
  16.   set the cursor of sprite mychannel = handcursor
  17.   return me
  18. end
  19.  
  20. on stepFrame me
  21.   if tracking then
  22.     snapTo(me)
  23.   end if
  24.   
  25. end
  26.  
  27. --if user drags sprite over the lockto rect..snap loc to the lockpoint
  28. on snapTo me
  29.   
  30.   set counter =1
  31.   repeat with i in LockTo
  32.     if inside(point(the mouseh,the MouseV),i) then
  33.       set the loc of sprite myChannel= getPropAt(lockTo,counter)
  34.       
  35.       if not(lockstate ) and the mouseup then
  36.         puppetsound "PieceGoesOn"
  37.         
  38.         set LockState = TRUE
  39.         if permanent then
  40.           
  41.           set the moveableSprite of sprite myChannel = FALSE 
  42.           delFromSIlist(myChannel,me)
  43.         end if
  44.       end if
  45.       exit repeat
  46.     else
  47.       if not(lockstate) then
  48.         set the loc of sprite myChannel = point(the mouseh,the mouseV)
  49.       end if
  50.     end if
  51.   end repeat
  52.   
  53. end
  54.  
  55. --if user drags sprite over the lockto rect..snap loc to the lockpoint
  56. on snapToCheck me
  57.   
  58.   set counter =1
  59.   repeat with i in LockTo
  60.     if inside(point(the mouseh,the MouseV),i) then
  61.       return true
  62.     end if
  63.     exit repeat
  64.     
  65.   end repeat
  66.   return false
  67. end
  68.  
  69. on checkState me
  70.   return LockState
  71. end
  72.  
  73.  
  74.  
  75. on Kill me
  76.   delFromSIlist(myChannel,me)
  77.   delfromactorlist(me)
  78.   set the cursor of sprite mychannel = -1
  79. end
  80.  
  81. on mouseDown me
  82.   set tracking = TRUE
  83. end
  84.  
  85. on mouseupOUtside me
  86.   set tracking = FALSE  
  87. end
  88.  
  89.  
  90. on mouseup me
  91.   global
  92.   
  93.   if permanent and snapToCheck(me) then
  94.     set LockState = TRUE
  95.     delFromSIlist(myChannel,me) 
  96.     nukeObj(nuke,me)
  97.     puppetsound "pieceGoesOn"
  98.   else
  99.     set the loc of sprite myChannel = origLoc
  100.     set tracking = False
  101.      
  102.   end if
  103. end